package com.taptech.doufu.ui.adapter

import android.content.Context
import androidx.core.content.ContextCompat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.taptech.doufu.R
import com.taptech.doufu.model.FilterItemBean
import kotlinx.android.synthetic.main.adapter_novle_category_layout.view.tvTitle

class FilterItemAdapter(context:Context): BaseRecyclerAdappter<FilterItemBean,FilterItemAdapter.ViewHolder>(context){

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(mContext).inflate(R.layout.adapter_filter_item_layout,null)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        val item = dataList[position]
        holder.itemView.tvTitle.text = item.name
        if (item.select){
            holder.itemView.tvTitle.setBackgroundResource(R.drawable.bg_1dp_e9e9e9_radius2)
            holder.itemView.tvTitle.setTextColor(ContextCompat.getColor(mContext, R.color.text_color_57))
        }else{
            holder.itemView.tvTitle.setBackgroundResource(R.drawable.bg_eef0f2_radius2)
            holder.itemView.tvTitle.setTextColor(ContextCompat.getColor(mContext,R.color.text_color_7))
        }

    }

    class ViewHolder(view: View): RecyclerView.ViewHolder(view)
}